package com.googlecode.gwtbb.client.only.widget.form;

import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.Widget;

/**
 * @author Abraham Grief
 * @version $Id$
 * @since Dec 21, 2008
 */
public abstract class FormDialogChangeListener implements FormStarter {
	protected String flagValue;

	protected FormDialogChangeListener(String flagValue) {
		this.flagValue = flagValue;
	}

	public String getFlagValue() {
		return flagValue;
	}

	public void setFlagValue(String flagValue) {
		this.flagValue = flagValue;
	}

	public FormWidget getForm() {
		return getFormStarter().getForm();
	}

	public abstract FormStarter getFormStarter();

	public void onChange(Widget sender) {
		ListBox listBox = (ListBox)sender;
		if (flagValue != null && flagValue.equals(listBox.getValue(listBox.getSelectedIndex())))
			startProcess();
	}
}
